﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Test : System.Web.UI.Page
{
    clsXuLy ex = new clsXuLy();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    protected void BindData()
    {

        DataTable dt = ex.GetData("sp_vnttblnhathau_ListDrop");
        int s = dt.Rows.Count;

        ddchkCountry.DataSource = dt;
        ddchkCountry.DataTextField = "TenNhaThau";
        ddchkCountry.DataValueField = "IDs";
        ddchkCountry.DataBind();
    } 
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        List<String> CountryID_list = new List<string>();
        List<String> CountryName_list = new List<string>();
       
        foreach (System.Web.UI.WebControls.ListItem item in ddchkCountry.Items)
        {
            if (item.Selected)
            {
                CountryID_list.Add(item.Value);
                CountryName_list.Add(item.Text);
            }
 
            lblCountryID.Text = "Country ID: "+ String.Join(",", CountryID_list.ToArray());
            lblCountryName.Text = "Country Name: "+ String.Join(",", CountryName_list.ToArray());
        } 
    }
}